/**
 * Object.is(obj1, obj2): return boolean
 * Object.assign(obj1, obj2...): return obj
 */

/**
 * Object.is(obj1, obj2): return boolean
 * 1. 对值类型和引用类型进行判等
 * 2. 对 NaN 的支持
 */
// 引用对象
const obj1 = {};
const obj2 = {};
console.log(Object.is(obj1, obj2)); // false
console.log(Object.is(NaN, NaN)); // true 对 NaN 的支持

// 值类型
const num1 = 10;
const num2 = 10;
const num3 = "10";
console.log(num1 == num3); // true 隐式转换
console.log(num1 === num3); // false 强类型判断
console.log(num1 === num2); // false 对象比较
console.log(NaN == NaN); // false
console.log(NaN === NaN); // false

/**
 * Object.assign(obj1, obj2...): return obj
 * 1. 对相同已存在的 key 会进行覆盖
 */

const name1 = { name: "hugo", city: "惠州", home: "汕头" };
const age = { age: 28, nickName: "bananafat" };
const name2 = { name: "hugo", city: "深圳", tel: "137****1836" };

const mergerObj = Object.assign(name1, age, name2);
console.log(mergerObj);

/**
 * Object.keys(obj): return array
 * Object.values(obj): return array
 * Object.entries(obj): return array
 */

const userInfo = {
  name: "hugo",
  age: 29,
  address: "惠州",
  tell: "137****1836",
};

console.log(Object.keys(userInfo));
console.log(Object.values(userInfo));
console.log(Object.entries(userInfo)); // 二维数组

for (let [key, val] of Object.entries(userInfo)) {
  console.log(`${key} <--> ${val}`);
}
